var mongoose = require('mongoose');
var config = require('config.default');
var logger = require('../common/logger')

// 连接数据库
mongoose.connect(config.db, {}, function (err) {
    if (err) {
        logger.error('connect to %s error: ', config.db, err.message);
        process.exit(1);
    }
});

// models
require('./account');
require('./account_role');
require('./authority');
require('./comment_like');
require('./numcode');
require('./role');
require('./role_authority');
require('./user');
require('./user_article');
require('./user_collect');
require('./user_focus');
require('./user_follow');

module.exports.Account = mongoose.model('account');
module.exports.AccountRole = mongoose.model('account_role');
module.exports.Authority = mongoose.model('authority');
module.exports.CommentLike = mongoose.model('comment_like');
module.exports.NumCode = mongoose.model('numcode');
module.exports.Role = mongoose.model('role');
module.exports.RoleAuthority = mongoose.model('role_authority');
module.exports.User = mongoose.model('user');
module.exports.UserArticle = mongoose.model('user_article');
module.exports.UserCollect = mongoose.model('user_collect');
module.exports.UserFocus = mongoose.model('user_focus');
module.exports.UserFollow = mongoose.model('user_follow');